package chapters15_bingfa.chapters15_3;

/**
 * Created by xinxuchu on 2020/1/28.
 */
public class Consumer extends Thread {

    MyBlockingQueue<String> queue;

    public Consumer(MyBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run(){
        try {
            while (true){
                String task = queue.take();
                System.out.println("handle task = " +task);
                Thread.sleep((int)(Math.random()*100));
            }

        }catch (InterruptedException e){

        }
    }
}
